<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
  <script>

    Function.prototype.mycall = function (context, ...args) {
      
      //不传对象；默认为window
      context = context || window;

      //定义一个fn属性缓存调用的对象；
      context.fn = this;

      //触发调用的这个函数
      const result = context.fn(...args);

      //删除this属性
      Reflect.deleteProperty(context, "fn");

      return result;
    }

    function add(a, b) {
      return a + b;
    }

    function plus(x, y) {
      return x - y ;
    }

    console.log(add.mycall(plus, 3, 1)); //4

  </script>

</body>
</html>